package ebiz.buddhist.texts;

import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import ebiz.buddhist.texts.data.DownItemAdapter;
import ebiz.buddhist.texts.data.DownItemList;
import com.nbpcorp.mobilead.sdk.MobileAdListener;
import com.nbpcorp.mobilead.sdk.MobileAdView;

public class Download extends Activity implements MobileAdListener {
	ArrayList<DownItemList> arItem;
	private MobileAdView adView = null;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_view);
		// adView 만들기
	      adView = (MobileAdView) findViewById(R.id.adview1);
	      adView.setListener(this);
		  adView.start();
		  
		arItem = new ArrayList<DownItemList>();
		DownItemList mi;

		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_sutra));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_beopseong));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_hwaeom));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_chunsu));
		arItem.add(mi);
		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_sinju));
		arItem.add(mi);
//		mi = new DownItemList(R.drawable.icon, "관무량수경독경");arItem.add(mi);
//		mi = new DownItemList(R.drawable.icon, "관세음보살보문품");arItem.add(mi);
//		mi = new DownItemList(R.drawable.icon, "관자재보살여의륜주");arItem.add(mi);
		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_gwaneum));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_ami));
		arItem.add(mi);
			
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kukrak));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_musang));
		arItem.add(mi);
		
	/* sekisuri 20140330
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kang1));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kang2));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kang3));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kang4));
		arItem.add(mi);
	*/	

		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_kor_heartsutra));
		arItem.add(mi);
		
	/*	
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows07));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows08));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows09));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows10));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows11));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows_s));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_bows_youngin));
		arItem.add(mi);

		*/
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_medicine_buddha));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.cundi));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.monks));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.zen_master));
		arItem.add(mi);
		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_chant));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_followyourheart));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_windy_hermitage));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_healing_music));
		arItem.add(mi);
		mi = new DownItemList(R.drawable.list_download, getString(R.string.Buddhist_hymn_3));
		arItem.add(mi);
		
//		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_diamond));
//		arItem.add(mi);
	//	mi = new DownItemList(R.drawable.icon2, "한글천수경");arItem.add(mi);
		
/*		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_sakyamuni));
		arItem.add(mi);
		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.item_guan));
		arItem.add(mi);

*/		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.mp3_meditation));
		arItem.add(mi);
		
		mi = new DownItemList(R.drawable.list_download, getString(R.string.mp3_meditation_2));
		arItem.add(mi);
		
		DownItemAdapter MyAdapter = new DownItemAdapter(this, R.layout.downlist, arItem);

		ListView MyList;
		MyList=(ListView)findViewById(R.id.list);
		MyList.setAdapter(MyAdapter);
		
		/*
		Button btn = (Button)findViewById(R.id.btn);
		btn.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {
				String str = arItem.get(pos).Name + "를 주문합니다.";
				Toast.makeText(Download.this, str, Toast.LENGTH_SHORT).show();
			}
		});
		
*/	}
	
	 public boolean onCreateOptionsMenu(Menu menu) {
			super.onCreateOptionsMenu(menu);
			menu.add(0,1,0,R.string.menu_reload).setIcon(R.drawable.ic_menu_reload);
			return true;
		}
		public boolean onOptionsItemSelected(MenuItem item) {
			switch (item.getItemId()) {
			case 1:	
				finish();
				Intent i = new Intent(Download.this,DownAndDelManager.class);
				startActivity(i);
				return true;
			}		
			return false;
		}
		@Override
		protected void onDestroy() {
			super.onDestroy();
			
			if (adView != null) {
				adView.destroy();
				adView = null;
			}
			
		}

		public void onReceive(int err) {
			// event for receive ad 
			
		}

	
}


